/*
 * @Author: 李金深 2896583081@qq.com
 * @Date: 2023-05-22 14:45:06
 * @LastEditors: 李金深
 * @LastEditTime: 2024-05-05 12:43:25
 * @FilePath: index.js
 * @Description:路由配置
 */
import { createRouter, createWebHistory } from 'vue-router'
import Index from '@/views/index.vue';
import Home from '@/views/home.vue';
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/index',
    },
    {
      path: '/index',
      component: Index,
    },
    {
      path: '/home',
      component: Home,
    }
  ]
})
router.beforeEach((to, from, next) => {
  // if (to.meta.auth) {
  //   let token = localStorage.getItem('USER_TOKEN')
  //   if (token) {
  //     if (from.path == '/email/write') {
  //       mitt.emit('pageJump', next)
  //     } else {
  //       next()
  //     }
  //   } else {
  //     mitt.emit('permissionCheckError')
  //   }
  // } else {
  //   next()
  // }
  next()
  document.documentElement.scrollTop = 0
})
export default router
